@extends('admin.layout.base')

@section('content')

    <div class="layui-form-item">
        <div class="layui-inline">
            <input class="layui-input search-data" name="name" placeholder="账户名" autocomplete="off">
        </div>

        <div class="layui-inline layui-form">
            <select name="status" class="search-data">
                <option value="">状态</option>
                <option value="0">启用</option>
                <option value="1">停用</option>
            </select>
        </div>

        <div class="layui-inline demoTable">
            <button class="layui-btn layui-btn-sm layuiadmin-btn-useradmin" data-type="search" lay-filter="search">
                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
            </button>
            @can('role.create')
            <button data-url="{{route("role.create")}}" data-type="openViews" class="layui-btn layui-btn-sm">添 加</button>
            @endcan
        </div>
    </div>

    <div class="layui-card">

        <table class="layui-hide" id="tableData" lay-filter="myTable"></table>
{{--
        <script type="text/html" id="toolbarDemo">
            <input class="layui-input" id="edtSearch" value="" placeholder="输入关键字" style="display: inline-block;width: 140px;height: 30px;line-height: 30px;padding: 0 5px;margin-right: 5px;"/>
            <div class="layui-btn-container" style="display: inline-block;">
                <button id="btnSearch" class="layui-btn layui-btn-sm layui-btn-primary">
                    <i class="layui-icon">&#xe615;</i>搜索
                </button>
                <button id="btnAdd" data-url="{{route("power.create")}}" class="layui-btn layui-btn-primary layui-btn-sm">添加</button>
            </div>
        </script>--}}
        <script type="text/html" id="status">
            <a lay-event="status">
                <input type="checkbox" data-url="{{route("role.status")}}" data-id="switch_@{{d.id}}" value="@{{d.status}}" @{{d.status==0?'checked':''}} lay-skin="switch" lay-text="启用|停用">
            </a>
        </script>

        <script type="text/html" id="options">
            <div class="layui-btn-group">
                @can('role.powerList')
                <a data-url="{{route("role.powerList")}}" lay-event="other" data-title="权限分配" data-width="100%" data-height="100%" class="layui-btn layui-btn-xs layui-btn-normal">权限</a>
                @endcan
                @can('role.edit')
                <a data-url="{{route("role.edit")}}" lay-event="edit" class="layui-btn layui-btn-xs layui-btn-normal">编辑</a>
                @endcan
                @can('role.delete')
                <a data-url="{{route("role.delete")}}" lay-event="del" class="layui-btn layui-btn-xs layui-btn-danger">删除</a>
                @endcan
            </div>
        </script>

    </div>

@endsection

@section('script')
    <script>
        layui.use(['table', 'layer', 'jquery'], function () {
            $ = layui.jquery;
            var table = layui.table;
            table.render({
                elem: '#tableData'
                , url: '{{route("role.list")}}'
                //,toolbar: '#toolbarDemo'
                //,defaultToolbar: ['filter', 'exports']
                , cols: [[
                    {field: 'id', title: 'ID', sort: true}
                    , {field: 'name', title: '角色名称'}
                    , {field: 'display', title: '显示名称'}
                    , {field: 'created_at', title: '创建时间'}
                    , {field: 'status', title: '状态', toolbar: '#status'}
                    , {fixed: 'right', width: 160, title: '操作', align: 'center', toolbar: '#options'}
                ]]
                , id: 'myReload'
                , page: true
            });
        });
    </script>
@endsection